import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-03-24
 * Time: 18:00
 */
public class NoSplitImpl implements NoSplitInter{
    /**
     * 字符串拆分成数组，如”ab&&2”通过”&&”做分隔符，分割得到字符串数组[“ab”,”2”]
     */

    private String str;

    ArrayList<String> list = new ArrayList<String>();

    public NoSplitImpl(String str){
        this.str = str;
    }

    @Override
    public void nosplit() {
        while(!str.isEmpty()){
            if(str.contains("&&")){
                int index = str.indexOf("&&");
                list.add(str.substring(0,index));
                str = str.substring(index+2);
            }else {
                list.add(str);
                break;
            }
        }
        System.out.println(list);
    }



}
